import address from "@/pages/address"
import addressEdit from "@/pages/address/edit"
import cart from "@/pages/cart"
import commit from "@/pages/commit"
import detail from "@/pages/detail"
import notice from "@/pages/notice"
import type from "@/pages/type"
import month from "@/pages/month"
import main from "@/pages/main"
import order from "@/pages/order"
import orderDetail from "@/pages/order/detail"
import expressInfo from "@/pages/order/expressInfo"
import goods from "@/pages/goods"
import my from "@/pages/my/newmy"
import user from "@/pages/user"
import userInfo from "@/pages/user/info"
import transferAccount from "@/pages/transfer/account"
import transferGoods from "@/pages/transfer/goods"
import store from "@/pages/store"
import share from "@/pages/share"
import SecCode from "@/pages/sec/Code.vue"
import out from "@/pages/login/out"
import login from "@/pages/login"
import loginSuccess from "@/pages/login/success"
import accountRecord from "@/pages/account/record"
import payment from "@/pages/account/payment"
import card from "@/pages/course/card"
import code from "@/pages/code"
import scan from "@/pages/scan"
import sign from "@/pages/course/sign"
import pointSign from "@/pages/sign"
import edit from "@/pages/my/edit"
import confirm from "@/pages/course/confirm"
import charge from "@/pages/transfer/charge"
import typeList from "@/pages/type/list"
import commission from "@/pages/commission/index"
import received from "@/pages/order/received"
import VueRouter from 'vue-router'
import auth from '@/pages/auth'
import form from '@/pages/goodsForm'
import manage from '@/pages/goodsmanage'
import freight from "@/pages/goodsForm/freight"
import demo from "@/pages/home/demo"
import freightEdit from "@/pages/goodsForm/freightEdit"
import comment from "@/pages/goodsmanage/comment"
import bulkManage from "../pages/goodsmanage/bulkManage"
import goodslist from "@/pages/goodslist"
import classify from '@/pages/type/class'
import text from "@/pages/text"
import newmy from "@/pages/my/newmy"
import wallet from '@/pages/wallet'
import totals from "@/pages/wallet/total"
import totalDetail from "@/pages/wallet/totalDetail"
import recharge from "@/pages/account/recharge"
import cards from "@/pages/account/card"
import collected from "@/pages/wallet/collected"
import collectDetail from "../pages/wallet/collectDetail"
import newOrder from "@/pages/order/newOrder"
import shareOrder from "@/pages/order/shareOrder"
import orderdetail from "@/pages/order/orderDetail"
import repertory from '@/pages/repertory'
import repertoryDetail from '@/pages/repertory/detail'
import links from "@/pages/repertory/links"
import earn from "@/pages/earn"
import earnDetail from '@/pages/earn/detail'
import shop from '@/pages/shop'
import shopGoodsList from '@/pages/shop/goodslist'
import newForm from "@/pages/goodsForm/newForm"
import Detail from '@/pages/detail/detail'
import grant from "../pages/my/grant";
import live from '@/pages/live'
import shopList from '@/pages/shopList'
import liveList from "../pages/live/liveList";
import appraise from '@/pages/detail/appraise'
import asking from '@/pages/detail/asking'
import answer from '@/pages/detail/answer'
import myAnswer from '@/pages/detail/myAnswer'
import lottery from "../pages/lottery/lottery";
import withdrawOld from "@/pages/order/withdraw"
import withdraw from "@/pages/withdraw"
import bank from "@/pages/withdraw/bank"
import withdrawEdit from '@/pages/withdraw/edit'
import material from "../pages/material/material";
import history from "../pages/material/history";
import release from "../pages/material/release";
import withdrawHome from "../pages/withdraw/home"
import shopDraw from "../pages/withdraw/shopDraw";
import lotteryDetail from "../pages/lottery/detail"
import redeem from "../pages/lottery/redeem";
import goodslistAgent from '@/pages/goodslist/agent'
import newHome from '../pages/home/home'
// import daily from '@/pages/daily'
import daily from '@/pages/daily'
//不同首页
let home
if(process.env.VUE_APP_NAME == 'wg'){
    home = () => import('@/pages/home')
}else{
    home = () => import('@/pages/home/home')
}
const routes = [
    {
        path: "/login",
        component: login
    },
    {
        path: "/sec/code",
        component: SecCode
    },
    {
        path: "/sec/box",
        component: SecCode,
        meta:{
            box:true
        }
    },
    {
        path: "/login/success",
        component: loginSuccess
    },
    {
        path: "/out",
        component: out
    },
    {
        path: "",
        component: main,
        redirect: '/home',
        children: [
            {
                path: "/account/record",
                component: accountRecord
            },
            {
                path: "/scan",
                component: scan
            },
            {
                path: "/auth",
                component: auth
            },
            {
                path: "/user",
                component: user
            },
            {
                path: "/code",
                component: code
            },
            {
                path: "/sign",
                component: sign,
                meta: {
                    notAlive: true
                }
            },
            {
                path: "/point/sign",
                component: pointSign,
            },
            {
                path: "/account/charge",
                component: charge,
                meta: {
                    notAlive: true
                }
            },
            {
                path: "/confirm",
                component: confirm
            },
            {
                path: "/card",
                component: card
            },
            {
                path: "/store",
                component: store
            },
            {
                path: "/account/payment",
                component: payment
            },

            {
                path: "/share",
                component: share
            },
            {
                path: "/transfer/account",
                component: transferAccount
            },
            {
                path: "/transfer/goods",
                component: transferGoods
            },
            {
                path: "/user/info",
                component: userInfo
            },
            {
                path: "/home",
                component: home
            },
            {
                path: "/my",
                component: my
            },
            {
                path: "/month",
                component: month
            },
            {
                path: "/my/edit",
                component: edit
            },
            {
                path: "/order",
                component: order
            },
            {
                path: "/goods",
                component: goods
            },
            {
                path: "/order/detail",
                component: orderDetail
            },{
                path: "/expressInfo",
                component: expressInfo
            },
            {
                path: "/detail",
                component: Detail
            },
            {
                path: "/newDetail",
                component: Detail
            },
            {
                path: "/address",
                component: address
            },
            {
                path: "/address/edit",
                component: addressEdit
            },
            {
                path: "/cart",
                component: cart
            },
            {
                path: "/commit",
                component: commit
            },

            {
                path: "/notice",
                component: notice
            },
            {
                path: "/type",
                component: type

            }, {
                path: "/type/list",
                component: typeList
            }, {
                path: "/commission",
                component: commission
            }, {
                path: "/received",
                component: received
            },{
                path:'/form',
                component: newForm
            },{
                path:'/manage',
                component: manage
            },{
                path : '/freight',
                component : freight
            },
            // {
            //     path : '/demo',
            //     component : demo
            // },
            {
                path : '/freight/edit',
                component : freightEdit
            },{
                path : '/manage/comment',
                component : comment
            },{
                path : '/manage/bulk',
                component : bulkManage
            },{
                path : '/goodslist',
                component : goodslist
            },{
                path : '/goodslist/agent',
                component : goodslistAgent
            }

            ,{
                path : '/type/classify',
                component : classify
            },{
                path : '/textdemo',
                component : text
            },{
                path : '/newmy',
                component : newmy
            },{
                path : '/wallet',
                component : wallet
            },{
                path : '/wallet/detail',
                component : totals
            },{
                path : '/wallet/totaldetail',
                component : totalDetail
            },{
                path : '/account/recharge',
                component : recharge,
                meta: {
                    notAlive: true
                }
            },
            {
                path: "/account/card",
                component: cards
            },
            ,{
                path : '/wallet/collected',
                component : collected
            },{
                path : '/wallet/collectdetail',
                component : collectDetail,
                name:'collectDetail'
            },{
                path : '/neworder',
                component : newOrder,
                meta: {
                    notAlive: true
                }
            },
            {
                path : '/shareOrder',
                component : shareOrder,
                meta: {
                    notAlive: true
                }
            },

            {
                path : '/orderdetail',
                component : orderdetail
            },{
                path : '/repertory',
                component : repertory

            },{
                path : '/repertory/detail',
                component : repertoryDetail,
                meta: {
                    notAlive: true
                }
            },{
                path : '/repertory/links',
                component : links
            },{
                path : '/earn',
                component : earn
            },{
                path : '/earn/detail',
                component : earnDetail
            },{
                path : '/shop',
                component : shop,
                meta: {
                    notAlive: true
                }
            },{
                path : '/shop/list',
                component : shopGoodsList
            },
            // {
            //     path : '/newform',
            //     component : newForm
            // }
            {
                path : '/grant',
                component : grant
            },{
                path : '/live',
                component : live,
                meta: {
                    notAlive: true
                }
            },{
                path : '/shopList',
                component : shopList
            },{
                path : '/liveList',
                component : liveList
            },{
                path : '/appraise',
                component : appraise
            },{
                path : '/asking',
                component : asking,
                meta : {
                    keepAlive: false
                }
            },{
                path : '/answer',
                component : answer
            },{
                path : '/myAnswer',
                component : myAnswer
            },
            {
                path : '/lottery',
                component : lottery
            },{
                path : '/order/withdraw',
                component : withdrawOld,
                meta: {
                    notAlive: true
                }
            }
            ,{
                path : '/withdraw',
                component : withdraw
            },{
                path : '/withdraw/bank',
                component : bank
            }
            ,{
                path : '/withdraw/edit',
                component : withdrawEdit
            },
            {
                path : '/material',
                component : material,
                meta: {
                    notAlive: true
                }
            },
            {
                path : '/material/history',
                component : history
            },{
                path : '/material/release',
                component : release
            },{
                path : '/withdraw/home',
                component : withdrawHome
            },{
                path : '/withdraw/shopDraw',
                component : shopDraw
            },{
                path : '/lottery/detail',
                component : lotteryDetail,
                meta: {
                    notAlive: true
                }
            },{
                path : '/lottery/redeem',
                component : redeem
            },{
                path : '/daily',
                component : daily
            },
            {
                path : '*',
                redirect : '/home'
            },




        ]
    }
]

const router = new VueRouter({
    base: process.env.NODE_ENV === 'production'
        ? process.env.VUE_APP_HEAD
        : '/',
    mode: 'history',
    routes: routes,
    scrollBehavior(to, from, savedPosition) {
        return {x: 0, y: 0}
    }
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router

